################################################################################
#
# iotgateway 
#
################################################################################

IOTGATEWAY_VERSION = 1.0.0
IOTGATEWAY_SITE = $(CURDIR)/excapp/IoT_Gateway
IOTGATEWAY_SITE_METHOD := local
IOTGATEWAY_INSTALL_STAGING := YES
IOTGATEWAY_INSTALL_TARGET := YES

define IOTGATEWAY_INSTALL_STAGING_CMDS
    $(INSTALL) -D -m 0755 $(@D)/src/IoT_Gateway $(STAGING_DIR)/backup/bin/IoT_Gateway
    $(INSTALL) -D -m 0644 $(@D)/files/devices_profile.json $(STAGING_DIR)/backup/data/devices_profile.json
    $(INSTALL) -D -m 0644 $(@D)/files/firmware.json $(STAGING_DIR)/backup/data/firmware.json
    $(INSTALL) -D -m 0644 $(@D)/files/scene.json $(STAGING_DIR)/backup/data/scene.json
    $(INSTALL) -D -m 0644 $(@D)/files/zm32.json $(STAGING_DIR)/backup/data/zm32.json
    $(INSTALL) -D -m 0755 $(@D)/files/S92iotd $(STAGING_DIR)/backup/etc/init.d/S92iotd
    $(INSTALL) -D -m 0755 $(@D)/files/S93iotmonitor $(STAGING_DIR)/backup/etc/init.d/S93iotmonitor
    $(INSTALL) -D -m 0755 $(@D)/files/iot_monitor.sh $(STAGING_DIR)/backup/bin/iot_monitor.sh
endef

define IOTGATEWAY_INSTALL_TARGET_CMDS
    $(INSTALL) -D -m 0755 $(@D)/src/IoT_Gateway $(TARGET_DIR)/backup/bin/IoT_Gateway
    $(INSTALL) -D -m 0644 $(@D)/files/devices_profile.json $(TARGET_DIR)/backup/data/devices_profile.json
    $(INSTALL) -D -m 0644 $(@D)/files/firmware.json $(TARGET_DIR)/backup/data/firmware.json
    $(INSTALL) -D -m 0644 $(@D)/files/scene.json $(TARGET_DIR)/backup/data/scene.json
    $(INSTALL) -D -m 0644 $(@D)/files/zm32.json $(TARGET_DIR)/backup/data/zm32.json
    $(INSTALL) -D -m 0755 $(@D)/files/S92iotd $(TARGET_DIR)/backup/etc/init.d/S92iotd
    $(INSTALL) -D -m 0755 $(@D)/files/S93iotmonitor $(TARGET_DIR)/backup/etc/init.d/S93iotmonitor
    $(INSTALL) -D -m 0755 $(@D)/files/iot_monitor.sh $(TARGET_DIR)/backup/bin/iot_monitor.sh
endef

define IOTGATEWAY_PERMISSIONS
    /backup/bin/IoT_Gateway f 0755 0 0 - - - - -
    /backup/data/devices_profile.json f 0666 0 0 - - - - -
    /backup/data/firmware.json f 0644 0 0 - - - - -
    /backup/data/scene.json f 0644 0 0 - - - - -
    /backup/data/zm32.json f 0644 0 0 - - - - -
    /backup/bin/iot_monitor.sh f 0755 0 0 - - - - -
    /backup/etc/init.d/S92iotd f 0755 0 0 - - - - -
    /backup/etc/init.d/S93iotmonitor f 0755 0 0 - - - - -
endef

$(eval $(cmake-package))
